{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As well as defining particular DAG-specific constraints in a constraints file (like obligatory arrows, etc) it is possible to arbitrary MIP constraints on the variables defning the BNSL problem - and to define new variables.\n",
    "\n",
    "To do this the user just defines a function called `mipconss` in the constraints file. This function takes a single argument which is the current Gobnilp object. Since this is also a Gurobi Model object we can use it to define new variables and constraints.\n",
    "\n",
    "For example, suppose we had the following in a file called `cons4.py`\n",
    "\n",
    "```\n",
    "from gurobipy import GRB\n",
    "\n",
    "def obligatory_arrows(gobnilp):\n",
    "    return [('A','E')]\n",
    "\n",
    "def mipconss(gobnilp):\n",
    "    orvar = gobnilp.addVar(obj=-1000,vtype=GRB.BINARY)\n",
    "    gobnilp.addGenConstrOr(orvar, [gobnilp.adjacency[frozenset(['A','B'])],\n",
    "                                    gobnilp.adjacency[frozenset(['A','F'])],\n",
    "                                    gobnilp.adjacency[frozenset(['D','E'])]])\n",
    "```\n",
    "The `obligatory_arrows` simply states that an arrow from A to E is required. `mipconss`, on the other hand, defines a new binary variable with objective value -1000 and constrains this variable to be true if and only if at least one of 3 adjacencies are the case.\n",
    "\n",
    "Let first of all learn a BN using `discrete.dat` without consulting `cons4.py`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using license file /home/james/gurobi.lic\n",
      "Academic license - for non-commercial use only\n",
      "Changed value of parameter PreCrush to 1\n",
      "   Prev: 0  Min: 0  Max: 1  Default: 0\n",
      "Changed value of parameter CutPasses to 100000\n",
      "   Prev: -1  Min: -1  Max: 2000000000  Default: -1\n",
      "Changed value of parameter GomoryPasses to 100000\n",
      "   Prev: -1  Min: -1  Max: 2000000000  Default: -1\n",
      "Changed value of parameter MIPFocus to 2\n",
      "   Prev: 0  Min: 0  Max: 3  Default: 0\n",
      "Changed value of parameter ZeroHalfCuts to 2\n",
      "   Prev: -1  Min: -1  Max: 2  Default: -1\n",
      "Changed value of parameter MIPGap to 0.0\n",
      "   Prev: 0.0001  Min: 0.0  Max: inf  Default: 0.0001\n",
      "Changed value of parameter MIPGapAbs to 0.0\n",
      "   Prev: 1e-10  Min: 0.0  Max: inf  Default: 1e-10\n",
      "**********\n",
      "BN has score -24028.0947783535\n",
      "**********\n",
      "A<- -5502.137377150637\n",
      "B<-A -3688.9395212202216\n",
      "C<- -3501.5105385969146\n",
      "D<-A,C -3555.014444236549\n",
      "E<-B,F -4310.304956470649\n",
      "F<- -3470.18794067853\n",
      "**********\n",
      "bnlearn modelstring = \n",
      "[A][B|A][C][D|A:C][E|F:B][F]\n",
      "**********\n",
      "CPDAG:\n",
      "Vertices: A,B,C,D,E,F\n",
      "A-B\n",
      "A->D\n",
      "B->E\n",
      "C->D\n",
      "F->E\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAbiUlEQVR4nO3de5zOZf7H8ddtBoOR8zFiaS3JeXYGEZ2UGOucpOKnJCFrNyzbViqxftk2sjqtRiEk4xArGxWSU44R/ZJDThFmxmEG4/798dmpbA4z3HNf3/u+38/HYx5pRjOfNL3nuj/f6/pcPr/fj4iIBEce1wWIiEQSha6ISBApdEVEgkihKyISRApdEZEgir7UB0uWLOmvXLlykEoREQkPa9euPez3+0td6GOXDN3KlSuzZs2a3KlKRCRM+Xy+XRf7mNoLIiJBpNAVEQkiha6ISBApdEVEgkihKyISRApdEZEgUuiKiASRQldEJIgUuiIiQaTQFREJIoWuiEgQKXRFRIJIoSsiEkSeCt3mzZtTrFgxMjIyXJciHjZlyhTi4uKIjY2lXLlytGzZkmXLlrkuSyRbPBO6O3fuZOnSpfh8Pub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V0QkiBS6IiJBpNAVEQkiha6ISBApdEVEgsjn9/sv/kGf7xCwK3jliIiEhUp+v7/UhT5wydAVEZHAUntBRCSIFLoiIkGk0BURCSKFrohIECl0RUSC6P8B1JLij/osaiAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from pygobnilp.gobnilp import Gobnilp\n",
    "m = Gobnilp()\n",
    "m.learn('discrete.dat',palim=None)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And now let's relearn using the constraints in `cons4.py`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -24831.592997736785\n",
      "**********\n",
      "A<- -5502.137377150637\n",
      "B<-D,E -4084.0547874724034\n",
      "D<-A,C -3555.014444236549\n",
      "E<-A -5255.121003198736\n",
      "C<- -3501.5105385969146\n",
      "F<-B,E -2933.7548470815454\n",
      "**********\n",
      "bnlearn modelstring = \n",
      "[A][B|D:E][D|A:C][E|A][C][F|E:B]\n",
      "**********\n",
      "CPDAG:\n",
      "Vertices: A,B,D,E,C,F\n",
      "A->D\n",
      "A->E\n",
      "B->F\n",
      "D->B\n",
      "E->B\n",
      "E->F\n",
      "C->D\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de1iUZfoH8O8wYOIRz6dMysxz5kIOmWm7HhrcUHTVyszOratlZmulZgcrSy3NNHOtXdNWS2sTT4ukmQcqFcjUFPHwEzy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"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m.learn('discrete.dat',palim=None,consfile='cons4')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Sure enough, the required arrow from A to E is there. None of the adjacencies mentioned in the 'or' constraint are found in the learned DAG which is not surprising since that would attract a penalty of 1000.\n",
    "\n",
    "If we we now to edit `cons4.py` so that 'or' variable has objective of +10000, we get the following DAG."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -24093.68982888259\n",
      "**********\n",
      "A<- -5502.137377150637\n",
      "B<-A -3688.9395212202216\n",
      "C<- -3501.5105385969146\n",
      "D<-A,C -3555.014444236549\n",
      "E<-A,B -4912.333100596723\n",
      "F<-B,E -2933.7548470815454\n",
      "**********\n",
      "bnlearn modelstring = \n",
      "[A][B|A][C][D|A:C][E|A:B][F|E:B]\n",
      "\n",
      " ** MIP solution objective is -23093.68982888259 ** \n",
      "\n",
      "**********\n",
      "CPDAG:\n",
      "Vertices: A,B,C,D,E,F\n",
      "A-B\n",
      "A->D\n",
      "A->E\n",
      "B-E\n",
      "B-F\n",
      "C->D\n",
      "E->F\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deViVVb/G8e8GIUBMxQHMcAScFUVRsl41p8wwM6e0LLPBMIfEDE2QIedscsiTvZpD5tBJEs35pCkOmYppiqC8YpaZmgMKyvScP9ZraZEh7r3XHn6f69pXybCfu8Gb5XrWs5bJMAyEEEJYh4vuAEII4UykdIUQwo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      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m.learn('discrete.dat',palim=None,consfile='cons4')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So now we get A and B connected. We also get a message that the objective value achieved by solving the MIP is 1000 better than the score of the BN. This is because the extra non-graphical 'or' variable has (invisibly) been set to 1."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
